<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>报表</title>
	<meta name ="description" content="弹窗">
	<link href="/layui/css/layui.css" rel="stylesheet"/>
	<style>
		.layui-form{
			padding-top:15px;
			padding-right: 15px;
		}
		ul.pagination {
			display: inline-block;
			padding: 0;
			margin: 0;
		}

		ul.pagination li {display: inline-block;border-radius: 10px;}

		ul.pagination li.active {
			background-color: #009688;
			border-radius: 5px;
		}
		ul.pagination li.active a{
			color: white;
		}
		ul.pagination li a {
			color: black;
			float: left;
			padding: 8px 16px;
			text-decoration: none;
			border: 1px solid #ddd; /* Gray */
		}
		.pull-right {
			float: right!important;
		}
	</style>
</head>
<body style="width: 80%;margin: 0 auto;">
<span style="float: left;margin-top: 10px;">欢迎你，<a href="#" style="color: cadetblue"><?php echo $username;?></a></span>
<a href="/report/logout" style="float: right;margin-top: 10px;color:cadetblue">退出登录</a>
<hr />
<ul class="layui-nav">
	<li class="layui-nav-item"><a href="/report/data">总览</a></li>
	<li class="layui-nav-item"><a href="/report/index">数据列表</a></li>
</ul>
<form class="layui-form" action="">
	<div class="layui-form-item">
		<?php if (isset($sonSource) && !empty($sonSource)) : ?>
			<label class="layui-form-label">请选择渠道</label>
			<div class="layui-input-inline" >
				<select name="s_id" id="sources" >
					<option value="0">可选择</option>
					<?php foreach ($sonSource as $key =>$value) : ?>
						<option value="<?php echo $value->id;  ?>" <?php if(isset($s_id) && $value->id==$s_id): ?>selected<?php endif; ?> ><?php echo  $value->name;  ?></option>
					<?php endforeach; ?>
				</select>
			</div>
		<?php else : ?>
			<label class="layui-form-label" style="width: 100px">请选择一级渠道</label>
			<div class="layui-input-inline">
				<select name="p_id" id="parent_source" lay-filter="parent_source">
					<option value="0">可选择</option>
					<?php foreach ($parentSource as $key =>$value) : ?>
						<option value="<?php echo $value->id;  ?>" <?php if(isset($p_id) && $value->id==$p_id): ?>selected<?php endif; ?> ><?php echo  $value->name;  ?></option>
					<?php endforeach; ?>
				</select>
			</div>
			<div class="layui-input-inline" >
				<select name="s_id" id="sources" >
					<option value="0">可选择</option>
					<?php foreach ($slist as $key =>$value) : ?>
						<option value="<?php echo $value->id;  ?>" <?php if(isset($s_id) && $value->id==$s_id): ?>selected<?php endif; ?> ><?php echo  $value->name;  ?></option>
					<?php endforeach; ?>
				</select>
			</div>
		<?php endif;?>
		<div class="layui-inline">
<!--			<label class="layui-form-label">选择日期</label>-->
<!--			<div class="layui-input-inline">-->
<!--				<input type="text" name="start-date" id="start-date" lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">-->
<!--			</div>-->
<!--			<div class="layui-input-inline">-->
<!--				<input type="text" name="end-date" id="end-date" lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">-->
<!--			</div>-->
			<div class="layui-input-inline">
				<button class="layui-btn" lay-submit="" lay-filter="demo1">查询</button>
			</div>
		</div>
	</div>
</form>
<table class="layui-table">
	<colgroup>
		<col width="150">
		<col width="150">
		<col width="150">
		<col width="150">
	</colgroup>
	<thead>
	<tr>
		<th>渠道</th>
		<th>电话</th>
<!--		<th>验证码</th>-->
<!--		<th>是否已验证</th>-->
		<th>上次登录</th>
		<th>注册时间</th>
	</tr>
	</thead>
	<tbody>
	<?php
	if (!empty($source)) :
	foreach ($source as $key =>$value) : ?>
	<tr>
		<td><?php echo  $value->name;  ?></td>
		<td><?php echo  $value->mobile;  ?></td>
<!--		<td>--><?php //echo  $value->yzm;  ?><!--</td>-->
<!--		<td>-->
<!--			--><?php //if($value->checked == 1) : ?>
<!--				<span>已验证</span>-->
<!--			--><?php //elseif($value->checked == 2) :?>
<!--				<span>验证不通过</span>-->
<!--			--><?php //else :?>
<!--				<span>未验证</span>-->
<!--			--><?php //endif;?>
<!--		</td>-->
		<td><?php echo  $value->lastlogin;  ?></td>
		<td><?php echo  $value->createtime;  ?></td>
	</tr>
	<?php endforeach; ?>
	<?php endif;?>
	</tbody>
</table>
<div class="pull-right">
	<?php echo $this->pagination->create_links(); ?>
</div>

<script src="/assets/js/building/jquery-1.11.1.min.js"></script>
<script src="/layui/lay/dest/layui.all.js"></script>
<script>
	layui.use(['form', 'layedit', 'laydate','laypage'], function(){
//		var laypage = layui.laypage;
//		laypage({
//			cont: $(".dataTables_paginate") //分页容器的id
//			,pages: 3 //总页数
//			,skin: '#5FB878' //自定义选中色值
//			,skip: true //开启跳页
//			,jump: function(obj, first){
//				if(!first){
//					window.location.href = 'http://new.udf.com/report/index?page='+ obj.curr;
//				}
//
//			}
//		});

	});

	var form = layui.form();
	form.on('select(parent_source)', function(data){
		console.log(data.value);
		if (data.value > 0) {
			$.ajax({
				method: "GET",
				url: "/report/ajax_source_data",
				data: {p_id:data.value}
			}).done(function(data){
				console.log(data);
				$("#sources").html(data);
				form.render('select');
			})
		} else {
			$("#sources").html('<option selected="selected" value="0">可选择</option>');
		}
	});


</script>
</body>
</html>